import java.util.Scanner;

public class gonggongzifuchuan {
    public static void main(String[] args) {
        Scanner in =new Scanner(System.in);
        String a=in.nextLine()+" ";
        String b=in.nextLine();
        String max = "";
        for (int i = 0; i < a.length(); i++) {
            for (int j = i; j < a.length(); j++) {
                String sub = a.substring(i, j);
                if ((b.indexOf(sub) != -1) && sub.length()> max.length()) {
                    max = sub;
                }
            }
        }
        System.out.println("Length of String1: "+(a.length()-1));
        System.out.println("Length of String2: "+b.length());
        System.out.println("Maxsubstring:"+max);
        System.out.println("Length of Maxsubstring: "+max.length());
    }
}
